#include<vector>
#include<iostream>
using std::vector;


class Solution {
public:
    void sortColors(vector<int>& nums) {
        int count0 = 0, count1 = 0;
        for (auto n : nums) {
            if (n == 0) count0++;
            if (n == 1) count1++;
        }
        for (int i = 0; i < count0; i++) {
            nums[i] = 0;
        }
        for (int i = count0; i < count0 + count1; i++) nums[i] = 1;
        for (int i = count0+count1; i < nums.size(); i++) nums[i] = 2;
    }
};